import { TRuneSwallow } from "../../../Message/Db/Tables/TRuneSwallow";
import { ItemConfig } from "./ItemConfig";
import { EBind } from "../../../Message/Public/EBind";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class RuneSwallowConfig
    
    export  class RuneSwallowConfig
    {
        constructor()
        {
            
            this.initConfig();
            return;
        }

        public getHolyRuneCanSwllowCodes(arg1: int): Array<any>
        {
            var loc5=null;
            var loc6=0;
            var loc1=this._data[arg1.toString()] as TRuneSwallow;
            if (loc1 == null) 
            {
                if (!((loc5 = ItemConfig.instance.getInfoByCode(arg1)) == null) && !(loc5.item == null) && loc5.item.bind == EBind._EBindYes) 
                {
                    loc1 = this._data[loc5.item.codeUnbind.toString()] as TRuneSwallow;
                }
            }
            if (loc1 == null) 
            {
                return [];
            }
            var loc2=[];
            var loc3=loc1.swallowCode.split("#");
            var loc4=0;
            while (loc4 < loc3.length) 
            {
                if ((loc6 = parseInt(loc3[loc4])) > 0) 
                {
                    loc2.push(loc6);
                }
                ++loc4;
            }
            return loc2;
        }

        /* internal  */initConfig(): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            this._data = new Map<any, any> /* flash.utils.Dictionary */();
            var loc1=ConfigManager.instance.getJSONByFileName("t_rune_swallow.json");
            var loc5=0;
            var loc6=loc1;
            for(loc2 of loc6) 
            {
                loc3 = new TRuneSwallow();
                this.copyValue(loc3, loc2);
                loc4 = loc3.itemCode.toString();
                this._data[loc4] = loc3;
            }
            return;
        }

        /* internal  */copyValue(arg1: Object, arg2: Object): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=arg2;
            for (loc1 in loc3) 
            {
                arg1[loc1] = arg2[loc1];
            }
            return;
        }

        public static get instance(): RuneSwallowConfig
        {
            if (RuneSwallowConfig._instance == null) 
            {
                RuneSwallowConfig._instance = new RuneSwallowConfig();
            }
            return RuneSwallowConfig._instance;
        }

        /* internal */ /* var */_data: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: RuneSwallowConfig;
    }
